package com.bjpowernode.boss.web.controller;

import com.bjpowernode.boss.common.enums.AjaxCode;
import com.bjpowernode.boss.web.models.result.AjaxResult;
import com.bjpowernode.boss.web.models.vo.PayWayVo;
import com.bjpowernode.boss.web.service.PayWayService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 支付方式
 *
 * @author shenlang
 * @date 2024-06-04 15:46
 * @version 1.0.0
 * TODO 添加描述
 */
@Controller
@ResponseBody
public class PayWayController {
    @Resource
    PayWayService payWayService;
    /**
     * 获取支付方式
     *
     * @return com.bjpowernode.boss.web.models.result.AjaxResult
     * @date 2024-06-04 16:22:38 16:22
     */
    @RequestMapping("/payWay/getPayWayTable")
    public AjaxResult getPayWayTable(){
        List<PayWayVo> payWayVos = payWayService.getPayWayTable();
        return new AjaxResult(AjaxCode.PAY_WAY_GET_SUCCESS,payWayVos);
    }
    /**
     * 改变支付方式状态
     *
     * @param id 支付方式id
     * @param status 支付方式状态
     * @return com.bjpowernode.boss.web.models.result.AjaxResult
     * @date 2024-06-04 16:23:43 16:23
     */
    @RequestMapping("/payWay/changeStatus")
    public AjaxResult changeStatus(@RequestParam String id,@RequestParam String status){
        boolean bool = payWayService.changeStatus(id,status);
        return new AjaxResult(AjaxCode.CHANGE_STATUS_SUCCESS,bool);
    }
    /**
     * 支付方式单删
     *
     * @param id 支付方式id
     * @return com.bjpowernode.boss.web.models.result.AjaxResult
     * @date 2024-06-04 16:32:42 16:32
     */
    @RequestMapping("/payWay/singleDeletePayWay")
    public AjaxResult singleDeletePayWay(@RequestParam String id){
        boolean bool = payWayService.singleDeletePayWay(id);
        return new AjaxResult(AjaxCode.DELETE__SUCCESS,bool);
    }
    /**
     * 支付方式批量删
     *
     * @param ids id集合
     * @return com.bjpowernode.boss.web.models.result.AjaxResult
     * @date 2024-06-04 16:41:47 16:41
     */
    @RequestMapping("/payWay/batchDeletePayWay")
    public AjaxResult batchDeletePayWay(@RequestParam List<String> ids){
        boolean bool = payWayService.batchDeletePayWay(ids);
        return new AjaxResult(AjaxCode.DELETE__SUCCESS,bool);
    }
    @RequestMapping("/payWay/getAllOptions")
    /**
     * 从内存或数据库中获取选项
     *
     * @return com.bjpowernode.boss.web.models.result.AjaxResult
     * @date 2024-06-04 21:42:57 21:42
     */
    public AjaxResult getAllOptions(){
        Map<String,Object> map = payWayService.getAllOptions();
        return new AjaxResult(AjaxCode.OPTIONS_GET_SUCCESS,map);
    }
}
